
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Manager Panel</title>

<%@include file="headerLink.jsp" %>
</head>


<body>
	<%
		if (session.getAttribute("manager") == null) {
			String readUrl = "../BrandContr";
			String updateUrl = "../BrandContr?command=update";
			String createUrl = "../BrandContr?command=create";
			String destroyUrl = "../BrandContr?command=delete";
	%>

	<jsp:include page="header.jsp"></jsp:include>

	<jsp:include page="menu.jsp"></jsp:include>

	<section id="main" class="column">
		<kendo:grid name="brandGrid" pageable="true" sortable="true" filterable="true" groupable="true">
			<kendo:grid-toolbar>
				<kendo:grid-toolbarItem name="create" text="Add new brand"/>
			</kendo:grid-toolbar>
			<kendo:grid-editable mode="inline" />
			<kendo:grid-columns>
				<kendo:grid-column title="ID" field="id"/>
				<kendo:grid-column title="Brand Name" field="name" />
				<kendo:grid-column title="Desciption" field="info" />
				<kendo:grid-column title="&nbsp;" width="180px">
					<kendo:grid-column-command>
						<kendo:grid-column-commandItem name="edit" text=""/>
						<kendo:grid-column-commandItem name="destroy" text=""/>
					</kendo:grid-column-command>
				</kendo:grid-column>
			</kendo:grid-columns>
			<kendo:dataSource pageSize="3" serverPaging="false">
				<kendo:dataSource-schema>
					<kendo:dataSource-schema-model id="id">
						<kendo:dataSource-schema-model-fields>
							<kendo:dataSource-schema-model-field name="id" type="number" editable="false"/>
							<kendo:dataSource-schema-model-field name="name" type="string" >
								<kendo:dataSource-schema-model-field-validation required="true" />
							</kendo:dataSource-schema-model-field>
							<kendo:dataSource-schema-model-field name="info" type="string" />
						</kendo:dataSource-schema-model-fields>
					</kendo:dataSource-schema-model>
				</kendo:dataSource-schema>
				<kendo:dataSource-transport>
					<kendo:dataSource-transport-create url="<%=createUrl%>"  type="POST" dataType="json" />
					<kendo:dataSource-transport-update url="<%=updateUrl%>" type="POST"/>
            		<kendo:dataSource-transport-destroy url="<%=destroyUrl%>" type="POST" />
					<kendo:dataSource-transport-read url="<%=readUrl%>" type="GET"/>
				</kendo:dataSource-transport>
			</kendo:dataSource>
		</kendo:grid>
		
	</section>
	<%
		} else {
	%>
	<script type="text/javascript">
		$.confirm({
			'title' : 'Not Authorized',
			'message' : 'You need to login first!!',
			'buttons' : {
				'OK' : {
					'class' : 'blue',
					'action' : function() {
						window.location.href = "manager_login.jsp";
					}

				}
			}
		});
	</script>
	<%
		}
	%>
</body>

</html>